package com.kuaidao.aggregation.feign.sys;


import com.kuaidao.common.constant.SysErrorCodeEnum;
import com.kuaidao.common.entity.JSONResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;

@FeignClient(name = "sys-server",fallback = UserFeignClient.HystrixClientFallback.class)
public interface UserFeignClient {

    @RequestMapping("/sys/user/hello")
    JSONResult helloWord();

    @Component
    static class HystrixClientFallback implements UserFeignClient{


        private JSONResult fallBackError(String name){
            return new JSONResult().fail(SysErrorCodeEnum.ERR_REST_FAIL.getCode(), SysErrorCodeEnum.ERR_REST_FAIL.getMessage());
        }

        @Override
        public JSONResult helloWord(){
            return fallBackError("获取helloword失败");
        }


    }


}
